//
//  NSString+Util.m
//  DaumComics
//
//  Created by yujeong on 10. 12. 17..
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "NSString+Util.h"

@implementation NSString(Util)
	
- (NSData *)UTF8Data {
	return [self dataUsingEncoding:NSUTF8StringEncoding];
}

- (NSString *)AES256EncryptWithKey:(NSString *)key
{
	
	NSData *plainData = [self dataUsingEncoding:NSUTF8StringEncoding];
	NSData *encryptedData = [plainData AES256EncryptWithKeyData:DBKEY];
	NSString *encryptedString = [encryptedData base64Encoding];
	return encryptedString;
}

- (NSString *)AES256DecryptWithKey:(NSString *)key
{
	NSData *encryptedData = [NSData dataWithBase64EncodedString:self];
	NSData *plainData = [encryptedData AES256DecryptWithKeyData:DBKEY];
	NSString *plainString = [[NSString alloc] initWithData:plainData encoding:NSUTF8StringEncoding];
	return [plainString autorelease];
}
@end
